package com.touzi.utils;

import com.touzi.beans.dbs.chanpin.Chanpin;
import com.touzi.beans.dbs.chanpin.NewChanpin;
import org.apache.http.HttpRequest;

import javax.servlet.http.HttpServletRequest;

public class ChanpinUtils {

    public static NewChanpin getNChanpinFromRequest(HttpServletRequest request) {
//        <%--biaoti | jiage | xiangou | fenhongcishu | fenhongzhouqi | shengyu | fenhong | paixu | keyong--%>
        String biaoti = request.getParameter("biaoti");
        String jiage = request.getParameter("jiage");
        String xiangou = request.getParameter("xiangou");
        String fenhongcishu = request.getParameter("fenhongcishu");
        String fenhongzhouqi = request.getParameter("fenhongzhouqi");
        String shengyu = request.getParameter("shengyu");
        String fenhong = request.getParameter("fenhong");
        String paixu = request.getParameter("paixu");
        String keyong = "yes";

        NewChanpin chanpin = new NewChanpin(biaoti, jiage, xiangou, fenhongcishu, fenhongzhouqi, shengyu, fenhong, paixu, keyong);
        return chanpin;
    }

    public static Chanpin getChanpinFromRequest(HttpServletRequest request) {
        String id = request.getParameter("id");
        String biaoti = request.getParameter("biaoti");
        String jiage = request.getParameter("jiage");
        String xiangou = request.getParameter("xiangou");
        String fenhongcishu = request.getParameter("fenhongcishu");
        String fenhongzhouqi = request.getParameter("fenhongzhouqi");
        String shengyu = request.getParameter("shengyu");
        String fenhong = request.getParameter("fenhong");
        String paixu = request.getParameter("paixu");
        String keyong = request.getParameter("keyong");

        Chanpin chanpin = new Chanpin(Integer.parseInt(id), biaoti, jiage, xiangou, fenhongcishu, fenhongzhouqi, shengyu, fenhong, paixu, keyong);
        return chanpin;
    }

}
